<?php

use PragmaRX\Random\Random;

class CreateAdmin extends \support\command\phinx\SeederBaseClass
{

    public function run()
    {
        $r = new Random();
        $salt = $r->alpha()->size(6)->get();
        $faker = Faker\Factory::create('zh_CN');
        $password = md5(md5(123456) . $salt );
        $admin = new \app\admin\model\Admin([
            'username'     => 'admin',
            'nickname'     => '超级管理员',
            'password'     => $password,
            'salt'         => $salt,
            'email'        => 'admin@test.com',
            'avatar'       => '/assets/admin/pear/admin/images/avatar.jpg',
            'loginfailure' => 0,
            'logintime'    => $faker->date("Y-m-d H:i:s"),
            'status'       => 'normal',
            'created_at'   => $faker->date("Y-m-d H:i:s"),
            'updated_at'   => $faker->date("Y-m-d H:i:s"),
        ]);
        $admin->save();
    }
}
